//
//  LLYSecondViewController.m
//  ZZ15091031LiuLeiYan
//
//  Created by qianfeng001 on 15/8/28.
//  Copyright (c) 2015年 刘雷岩. All rights reserved.
//

#import "LLYSecondViewController.h"

@interface LLYSecondViewController ()
{
    UIView *_blueView;
    UIView *_redView;
    
    CGAffineTransform _transform;
}

@end

@implementation LLYSecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
//    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.hidden = YES;
    [self createSlider];
    [self createView];
}

- (void)createSlider {
    UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 50, 300, 20)];
    slider.minimumValue = 1;
    slider.maximumValue = 3;
    slider.value = 0;
    [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
    
    [self.view addSubview:slider];
}

- (void)sliderChanged:(UISlider *)slider {
    
//    _redView.transform = CGAffineTransformMakeScale(slider.value, slider.value);
    
    [UIView animateWithDuration:0.3 animations:^{
        _redView.transform = CGAffineTransformScale(_transform, slider.value, slider.value);
    } completion:^(BOOL finished) {
        
    }];
    
}

- (void)createView {
    _blueView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 80, 80)];
    _blueView.backgroundColor = [UIColor blueColor];
    _blueView.layer.borderWidth = 5;
    _blueView.layer.borderColor = [UIColor redColor].CGColor;
    
    _redView = [[UIView alloc] initWithFrame:CGRectMake(125, 200, 100, 100)];
    _redView.autoresizesSubviews = YES;
    _redView.autoresizingMask =UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
    _transform = _redView.transform;
    [_redView addSubview:_blueView];
    [self.view addSubview:_redView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
